package com.axin.common.entity;
/**
 * 通过此对象封装控制层返回的结果
 * @Description: TODO 
 * @ClassName:  JsonResult
 * @author:  Axin 
 * @date:   2019年3月11日 下午10:11:09   
 * @Copyright: 2019 www.hao456.top Inc. All rights reserved.
 */
public class JsonResult {
	
	
	/**表示成功*/
	public static final int SUCCESS=200;
	/**表示失败*/
	public static final int ERROR=500;
	/**表示超时*/
	public static final int TIMEOUT=100;
	
	/**状态 */
	private int status;
	/**信息(给用户提示的信息)*/
	private String message;
	/**具体业务数据*/
	private Object data;
	
	
	public JsonResult(){
		this.status=SUCCESS;
		this.message="OK";
	}
	
	public JsonResult(Object data){
		this();//调用当前类的构造方法
		this.data=data;
	}
	
	public JsonResult(Object data,String message){
		this(data);//调用当前类的构造方法
		this.message=message;
	}
	
	public JsonResult(Throwable e){
		this.status=ERROR;
		this.message=e.getMessage();
	}

	
	public static JsonResult success(String message){
		JsonResult result = new JsonResult(null,message);
		return result;
	}
	/**
	 * @return the status
	 */
	public int getStatus() {
		return status;
	}

	/**
	 * @param status the status to set
	 */
	public void setStatus(int status) {
		this.status = status;
	}

	public String getMessage() {
		return message;
	}


	public void setMessage(String message) {
		this.message = message;
	}


	public Object getData() {
		return data;
	}


	public void setData(Object data) {
		this.data = data;
	}


	public static int getSuccess() {
		return SUCCESS;
	}


	public static int getError() {
		return ERROR;
	}
	
	

}
